package com.dennisstepp.tabwidget;

import com.dennisstepp.R;
import com.dennisstepp.activities.SuperheroActivity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class SuperheroTabWidget extends TabActivity{
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tablayout);
		
		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity tab host
		TabHost.TabSpec spec;			// Reusable TabSpec for each tab
		Intent intent;					// Reusable Intent for each tab
		
		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, SuperheroActivity.class);
		
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("superhero").setIndicator("Superhero",
				res.getDrawable(R.drawable.ic_tab_superhero))
				.setContent(intent);
		tabHost.addTab(spec);
		
		// Do the same for more tabs
		
		// Set the current tab
		tabHost.setCurrentTab(1);
	}

}
